package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.BangDingFamilyDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.FamilyMemberVo;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author Tomorrow
 * @date 2025-01-09
 */
@Api(tags = "老人家属管理")
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController extends BaseController {
    @Autowired
    private IFamilyMemberService familyMemberService;


    /**
     * 小程序登录
     */
    @PostMapping("/login")
    public R<LoginVo> login(@RequestBody UserLoginRequestDto userLoginRequestDto) {

        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return R.ok(loginVo);
    }


    /**
     * 小程序绑定家人
     *
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BangDingFamilyDto bangDingFamilyDto) {

        familyMemberService.add(bangDingFamilyDto);
        return AjaxResult.success("保存成功");

    }

    /**
     * 小程序查询家人列表
     * @return
     */
    @GetMapping("/my")
    public List<FamilyMemberVo> selectFamilyMember(){

        return familyMemberService.selectFamilyMember();
    }


}
